tab对于需要 共享 的代码而言是灾难。
pyhton对这点的明确要求是不要混合使用4个空格和tab键.
只使用二者之一,都是没有问题的.如果一个python代码已经完成的部分,都是使用的4个空格.那么这个时候,就不可以插入tab键,而必须使用空格.
不同的平台对tab展开空格的个数的显示效果并不相同.使用空格的好处是,可以使得各个平台下,效果完全一致.
sublime text 3 显示空格和Tab¶
sublime显示制表符
"draw_white_space": "all"
如果”:“符号提示错误,说明你原来有语句,在最后面那个加上逗号”,“,然后最后一句添加刚刚的 “draw_white_space”: “all”
Sublime text3修改tab键为缩进为四个空格¶
sublime-settings-User里,添加如下三行 自动转换tab为空格
1 2 3 4 5 6 | // The number of spaces a tab is considered equal to "tab_size": 4, // Set to true to insert spaces when tab is pressed "translate_tabs_to_spaces": true, //设置保存时自动转换 "expand_tabs_on_save": true |